package net.icontents.service.impl;

import java.util.List;

import org.springframework.beans.factory.InitializingBean;

import net.icontents.dao.BaseDao;
import net.icontents.service.BaseService;

public abstract class BaseServiceImpl<T> implements BaseService<T>,InitializingBean{

    private BaseDao<T> baseDao;

    public BaseDao<T> getBaseDao() {
        return baseDao;
    }

    public void setBaseDao(BaseDao<T> baseDao){
        this.baseDao=baseDao;
    }
    @Override
    public void afterPropertiesSet() throws Exception {
        setBaseDaoHandlewired();
    }
    
    public abstract void setBaseDaoHandlewired();

    @Override
    public void deleteById(long id) {
        baseDao.deleteById(id);
    }

    @Override
    public void deleteById(String id) {
        baseDao.deleteById(id);
    }

    @Override
    public T getObjectById(long id) {
        return baseDao.getObjectById(id);
    }

    @Override
    public int getTotal() {
        return baseDao.getTotal();
    }

    @Override
    public int insert(T obj) {
        return baseDao.insert(obj);
    }

    @Override
    public void markObjectById(long id, int mark) {
        baseDao.markObjectById(id, mark);
    }
    @Override
    public void markObjectById(long id, int mark,boolean isUnmark) {
        baseDao.markObjectById(id, mark,isUnmark);
    }

    @Override
    public List<T> select(int page, int size) {
        return baseDao.select(page, size);
    }

    @Override
    public List<T> selectMarked(int page, int size) {
        return baseDao.selectMarked(page, size);
    }

    @Override
    public void update(T obj) {
        baseDao.update(obj);
    }
}
